package ca.paulshin.yunatube.youtube;

import android.app.Activity;
import android.app.Dialog;
import android.view.View;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;
import ca.paulshin.yunatube.R;
import ca.paulshin.yunatube.common.Utils;

public class ReportDialog extends Dialog {
	private RadioGroup radioReportGroup;

	public ReportDialog(final Activity activity, final String title, final String url) {
		super(activity, R.style.Theme_YunaTubeDialog);
		this.setContentView(R.layout.dialog_report);
		this.setCancelable(true);

		radioReportGroup = (RadioGroup) findViewById(R.id.report_type);
		
		TextView ui_close = (TextView) findViewById(R.id.search_close);

		ui_close.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				dismiss();
			}
		});
		
		radioReportGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() 
	    {
	        public void onCheckedChanged(RadioGroup group, int checkedId) {
	            switch(checkedId) {
	            case R.id.report_type_deleted:
	    			Utils.emailToMe(activity, activity.getString(R.string.report_type_deleted_title), activity.getString(R.string.report_type_text) + " Title: " + title + " / URL: http://youtu.be/" + url);
	            	break;
	            case R.id.report_type_nomobile:
	            	Utils.showToast(activity, activity.getString(R.string.report_type_nomobile_desc), false);
	    			Utils.emailToMe(activity, activity.getString(R.string.report_type_nomobile_title), activity.getString(R.string.report_type_text) + " Title: " + title + " / URL: http://youtu.be/" + url);
	            	break;
	            case R.id.report_type_suspended:
	    			Utils.emailToMe(activity, activity.getString(R.string.report_type_suspended_title), activity.getString(R.string.report_type_text) + " Title: " + title + " / URL: http://youtu.be/" + url);
	            	break;
	            }
	            dismiss();
	        }
	    });
	}
}
